<?php 
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Class FrontController extends CI_Controller{
	
	
	public function index(){
		redirect("frontcontroller/home");
	}
	
	public function home(){
		//$this->load->view("index");
		$this->listPosts();
	}
	
	public function database(){
		$this->load->model("dao/PostDao");
		$this->load->model("dto/PostDto");
		$this->PostDto->setCategoryname("database");
		$data["cate"] = $this->PostDao->listPost($this->PostDto);
		$this->load->view("index" , $data );
	}
	
	public function programming(){
		$this->load->model("dao/PostDao");
		$this->load->model("dto/PostDto");
		$this->PostDto->setCategoryname("Programming");
		$data["cate"] = $this->PostDao->listPost($this->PostDto);
		$this->load->view("index" , $data );
	}
	public function web(){
		$this->load->model("dao/PostDao");
		$this->load->model("dto/PostDto");
		$this->PostDto->setCategoryname("Web");
		$data["cate"] = $this->PostDao->listPost($this->PostDto);
		$this->load->view("index" , $data );
	}
	
	public function contactus(){
		$this->load->view("index");
	}
	
	public function category(){
		$this->load->view("index");
	}
	
	public function test(){
		$this->load->view("index");
	}
	
	public function single_post(){
		$this->load->model("dao/PostDao");
		$this->load->model("dto/PostDto");
		$this->PostDto->setPostid(1);
		$data["detail"] = $this->PostDao->listPost($this->PostDto);
		$this->load->view("index" , $data );
	}
	
	
	private function listPosts(){
		$this->load->model("dao/PostDao");
		$this->load->model("dto/PostDto");
		
		$data["posts"] = $this->PostDao->listPost($this->PostDto);
		//echo $data["posts"] -> num_row;
		$this->load->view("index" , $data);
	}
}